home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / gtlayout-source.lha / LT_IMsg.c < prev    next >
C/C++ Source or Header  |  1995-09-24  |  3KB  |  104 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. #define MESSAGE_COOKIE 0x19138AFB
  10.  
  11. struct IntuiMessage * LIBENT
  12. LT_GetIMsg(REG(a0) struct LayoutHandle *Handle)
  13. {
  14.     if(Handle)
  15.     {
  16.         struct IntuiMessage *Msg = GT_GetIMsg(Handle -> Window -> UserPort);
  17.  
  18.         if(Msg)
  19.         {
  20.             struct IntuiMessage *Clone;
  21.  
  22.                 // For multiple handles sharing the same UserPort
  23.  
  24.             if(Msg -> IDCMPWindow -> UserData && !((ULONG)Msg -> IDCMPWindow -> UserData & 1))
  25.             {
  26.                 LayoutHandle *Local = (LayoutHandle *)Msg -> IDCMPWindow -> UserData;
  27.  
  28.                 if(Local -> PointBack == Local)
  29.                     Handle = Local;
  30.                 else
  31.                     return(Msg);
  32.             }
  33.             else
  34.                 return(Msg);
  35.  
  36.             if(Msg -> Class == IDCMP_SIZEVERIFY && Handle -> ResizeView)
  37.             {
  38.                     // They're coming to take me away, HAHA!
  39.  
  40.                 Handle -> SizeVerified    = TRUE;
  41.                 Handle -> SizeWidth    = Handle -> Window -> Width;
  42.                 Handle -> SizeHeight    = Handle -> Window -> Height;
  43.  
  44.                 RemoveGList(Handle -> Window,Handle -> List,(UWORD)-1);
  45.  
  46.                     // Fake a null event, otherwise the following
  47.                     // IDCMP_NEWSIZE would probably not get through
  48.  
  49.                 if(Clone = (struct IntuiMessage *)AllocMem(sizeof(struct IntuiMessage),MEMF_ANY))
  50.                 {
  51.                     CopyMem(Msg,Clone,sizeof(struct IntuiMessage));
  52.  
  53.                     Clone -> Class                    = NULL;
  54.                     Clone -> ExecMessage . mn_Node . ln_Name    = (char *)MESSAGE_COOKIE;
  55.                     Clone -> ExecMessage . mn_Node . ln_Pri     = -114;
  56.                     Clone -> ExecMessage . mn_ReplyPort        = (struct MsgPort *)Clone;
  57.                     Clone -> SpecialLink                = (struct IntuiMessage *)Clone;
  58.  
  59.                     GT_ReplyIMsg(Msg);
  60.                 }
  61.             }
  62.             else
  63.             {
  64.                 if(Clone = (struct IntuiMessage *)AllocMem(sizeof(struct IntuiMessage),MEMF_ANY))
  65.                 {
  66.                     CopyMem(Msg,Clone,sizeof(struct IntuiMessage));
  67.  
  68.                     Clone -> ExecMessage . mn_Node . ln_Name    = (char *)MESSAGE_COOKIE;
  69.                     Clone -> ExecMessage . mn_Node . ln_Pri     = -114;
  70.                     Clone -> ExecMessage . mn_ReplyPort        = (struct MsgPort *)Clone;
  71.                     Clone -> SpecialLink                = (struct IntuiMessage *)Clone;
  72.  
  73.                     GT_ReplyIMsg(Msg);
  74.  
  75.                     LT_HandleInput(Handle,Clone -> Qualifier,&Clone -> Class,&Clone -> Code,(struct Gadget **)&Clone -> IAddress);
  76.                 }
  77.             }
  78.  
  79.             if(Clone)
  80.                 return(Clone);
  81.             else
  82.                 GT_ReplyIMsg(Msg);
  83.         }
  84.     }
  85.  
  86.     return(NULL);
  87. }
  88.  
  89.  
  90. /*****************************************************************************/
  91.  
  92.  
  93. VOID LIBENT
  94. LT_ReplyIMsg(REG(a0) struct IntuiMessage *Msg)
  95. {
  96.     if(Msg)
  97.     {
  98.         if(Msg -> SpecialLink == (struct IntuiMessage *)Msg && Msg -> ExecMessage . mn_Node . ln_Name == (char *)MESSAGE_COOKIE && Msg -> ExecMessage . mn_Node . ln_Pri == -114 && Msg -> ExecMessage . mn_ReplyPort == (struct MsgPort *)Msg)
  99.             FreeMem(Msg,sizeof(struct IntuiMessage));
  100.         else
  101.             GT_ReplyIMsg(Msg);
  102.     }
  103. }
  104.